<style scoped>
._hide{opacity: 0;}
._input1{width:150px;height: 24px;}
.input_cs{position: absolute;bottom:0px;width:80%;right:10%;}
.input_cs input{text-align: right;border:0px;background:none;}
.icu{width:8%;float:left;margin-top:6px;}
</style>
<template>
<div>
    <Card :bordered="false" dis-hover>
        <p slot="title">电票开具</p>
        <div class="div_box1">
            <Row :gutter="20">
                <Col span="17" style="text-align:left;font-size:12px;line-height:30px;">
                    <!-- 发票代码    <input class="_input1" v-model="obj.invoiceCode" ref="invoiceCode" tabIndex="1"> -->
                    <Select    style="width:200px" v-model="obj.invoiceTypeCode" 
                    placeholder="选择发票类型" tabIndex="2">
                        <Option  value="1" >增值税普通发票</Option>
                    </Select>
                </Col>
                <Col span="7" style="text-align:center;font-size:12px;line-height:30px;">
                  开票日期  
                    <DatePicker type="date" v-model="date" @on-change="setdate" style="width: 140px" 

                    ></DatePicker>

                </Col>
            </Row>
            <br/>
            <div>
                <Row :gutter="10" style="font-size:12px;"  class="r1">
                    <Col span="1" style="text-align:center;">购<br/>买<br/>方</Col>
                    <Col span="15" class="bor_left">
                        <p>名称：</p>
                        <AutoComplete
                            size="small"
                            v-model="obj.buyerName"
                            @on-search="searchName"
                            @on-select="afterSelectName"
                            class="input1" :clearable="true">
                            <Option v-for="item in autoData" :value="item.companyName" :key="item.guid">{{ item.companyName }}</Option>
                            </AutoComplete></br>
                        <!-- <input  v-model="obj.buyerName"  ref="buyerName" searchTax> -->
                        
                        <p>纳税人识别号:</p>
                        <AutoComplete
                            size="small"
                            v-model="obj.buyerTaxNo"
                            @on-search="searchTax"
                            @on-select="afterSelectTax"
                            class="input1" :clearable="true">
                            <Option v-for="item in autoData" :value="item.companyTax" :key="item.guid">{{ item.companyTax }}</Option>
                            </AutoComplete></br>
                        <!-- <input class="input1"   v-model="obj.buyerTaxNo" style="margin-left:0px;" ref="buyerTaxNo"> -->
                        <p>地 址、电 话:</p>
                        <Input class="input1" size="small" clearable v-model="obj.buyerAddressPhone" tabIndex="5"/></br>
                        <p>开户行及帐号:</p>
                        <Input class="input1"  size="small" clearable v-model="obj.buyerBankAccount" tabIndex="6"/>
                    </Col>
                    <Col span="1" class="bor_left" style="height:120px;text-align:center;">密<br/>码<br/>区</Col>
                    <Col span="7" class="bor_left" style="height:120px;"></Col>
                </Row>
                <Row :gutter="10" class="r2">
                    <Col span="5">
                        货物或应税劳务、服务名称</br>
                        <!-- @change="inputchange(item,index)" -->
                        <span v-for="(item,index) in obj.invoiceDetailList" 
                        style="width:100%;height:26px;">
                            
                            <i  class="ivu-icon ivu-icon-close icu"  @click="remove(item,index)"
                            ></i>
                            <input type="text"  style="width:92%;"
                            v-model="item.goodsName" :tabIndex=" 6+(index*7)+1" 
                            ref="goodsName" @click="showtitle(item,index,$event)" readonly="" >
                        </span>
                        <i 
                        style="font-size:16px;position: absolute;left: 0%;bottom: 50px;text-align:center;width:100%;color:#333;" 
                        >
                           <Button  @click="add()" type="warning"  size="small" shape="circle" icon="plus-round">添加明细</Button>
                        </i>
                        
                        </br>
                        <p class="p1">（明细最多100条）<br/>合计</p>
                    </Col>
                    <Col span="4" class="bor_left2">
                        规格型号</br>
                        <input v-for="(item,index) in obj.invoiceDetailList" v-model="item.goodsSpecification"  :tabIndex=" 6+(index*7)+2" 
                        @keyup.enter="enter(index,2)">
                        <p class="p1 _hide"></p>
                    </Col>
                    <Col span="2"  class="bor_left2">单位
                        <input v-for="(item,index) in obj.invoiceDetailList" v-model="item.goodsUnit" :tabIndex=" 6+(index*7)+3" 
                        @keyup.enter="enter(index,3)">
                        <p class="p1 _hide"></p>
                    </Col>
                    <Col span="2"  class="bor_left2">数量
                        <input onkeyup="value=value.replace(/[a-zA-Z]/g,'') "
                        v-for="(item,index) in obj.invoiceDetailList" v-model="item.goodsQuantity" @change="invnum(item)" ref="goodsQuantity" 
                        :tabIndex=" 6+(index*7)+4" @keyup.enter="enter(index,4)">
                        <p class="p1 _hide"></p>
                    </Col>
                    <Col span="2"  style="    border-left: 1px #e7922d solid;">单价
                        <input onkeyup="value=value.replace(/[a-zA-Z]/g,'') "
                         v-for="(item,index) in obj.invoiceDetailList" v-model="item.goodsPrice"  @change="money(item)" ref="goodsPrice" 
                         :tabIndex=" 6+(index*7)+5" style="text-align:right;" 
                         @keyup.enter="enter(index,5)">
                        <p class="p1 _hide"></p>
                    </Col>
                    <Col span="3"  class="bor_left2" style="border-right:1px #e7922d solid;">金额
                        <input v-for="item in obj.invoiceDetailList" v-model="item.goodsTotalPrice" disabled="" 
                         style="text-align:right;">
                        <p class="p1 _hide"></p>

                        <span class="input_cs">
                            <input type="text"  disabled :value="'￥'+obj.invoiceTotalPrice"  />
                        </span>
                    </Col>
                    <Col span="3"  class="bor_left2" style="border:0px;">税率<br/>
                         
                         <span  v-for="(item,index) in obj.invoiceDetailList">
                             <input    v-model="item.goodsTaxRate"  style="width:80%;text-align:right;" ref="goodsTaxRate" :tabIndex=" 6+(index*7)+6" 
                             @change="settax(item,index)"  @keyup.enter="enter(index,6)">%
                         </span>
                         
                    </Col>
                    <Col span="3" class="bor_left2">税额
                        <input style="text-align:right; " v-for="(item,index) in obj.invoiceDetailList" v-model="item.goodsTotalTax"   ref="goodsTotalTax" :tabIndex=" 6+(index*7)+7" disabled="">
                        <p class="p1 _hide"></p>
                        <span class="input_cs">
                            <input type="text"  disabled :value="'￥'+obj.invoiceTotalTax"  />
                        </span>
                    </Col>
                </Row>
                <Row :gutter="10" class="r3">

                    <Col span="5" style="text-align:center;">价税合计（ 大 写 ）</Col>
                    <Col span="19" class="bor_left3">


                    <input type="text"  disabled="" 
                    style="margin-right:20%;width:40%;margin-left:2%;" 
                    v-model="obj.invoiceTotalPriceb"> 
                    (小写)&nbsp;&nbsp;<input type="text" disabled=""  
                     :value="'￥'+obj.invoiceTotalPriceTax"></Col>
                </Row>
                <Row :gutter="10" class="r4">
                    <Col span="1" style="text-align:center;">销<br/>售<br/>方</Col>
                    <Col span="11" class="bor_left4">
                        <p>名称：</p>   
                        <input class="input1" disabled v-model="obj.sellerName" ref="sellerName" :tabIndex=" 6+(obj.invoiceDetailList.length*7)+1"></br>
                        <p>纳税人识别号:</p>
                        <input class="input1" disabled v-model="obj.sellerTaxNo"  ref="sellerTaxNo" :tabIndex=" 6+(obj.invoiceDetailList.length*7)+2"></br>
                        <p>地 址、电 话:</p>
                        <input class="input1" disabled v-model="obj.sellerAddressPhone" :tabIndex=" 6+(obj.invoiceDetailList.length*3)+1"></br>
                        <p>开户行及帐号:</p> 
                         <input class="input1" disabled v-model="obj.sellerBankAccount"  :tabIndex=" 6+(obj.invoiceDetailList.length*7)+4" >
                    </Col>
                    <Col span="1" class="bor_left4"  style="text-align:center;">备<br/><br/>注</Col>
                    <Col span="11" class="bor_left4">校验码</Col>
                </Row>
                <p class="p_5">
                    <span>收 款 人 ：
                        <Input class="_input1" size="small" v-model="obj.payee" ref="payee" :tabIndex=" 6+(obj.invoiceDetailList.length*7)+5"/></span>
                    <span>复核 ：
                        <Input class="_input1" size="small" v-model="obj.checker"  ref="checker" 
                        :tabIndex=" 6+(obj.invoiceDetailList.length*7)+6"/></span>
                    <span>开票人 ：
                        <Input class="_input1" size="small" v-model="obj.drawer" ref="drawer"
                        :tabIndex=" 6+(obj.invoiceDetailList.length*7)+7"/></span>
                    <span>销售方 ： （章）</span>
                </p>
                
            </div>
        </div>

        <p  >
            <Button type="primary" @click="submit('addForm')" >开票</Button>
        </p>
    </Card>
   	<library-edit @refresh="setdata"></library-edit>
</div>	
</template>
<script>
import LibraryEdit from "../Module/libraryedit.vue";
export default {
	components:{LibraryEdit},
	data (){
         return {
             modal:false,title:'进项发票录入',date:'',
             obj:{mail:'',invoiceDetailList:[
                {goodsName:'',goodsTotalPrice:null}
             ],invoiceDate:''},
             ruleValidate:{
                 mail:[
                     { required: true, message: 'email不能为空', trigger: 'blur' },
                     {type:'email',message:'email 格式不正确',trigger:'blur'}
                 ]
             },c:{},
             autoData:[],
             timeout:0,
         }
     },methods:{
         searchTax(value){
             let param = {"companyTax":value};
             this.autoSearch(param);
         },
         searchName(value){
             let param = {"companyName":value};
             this.autoSearch(param);
         },
         afterSelectTax(value){
             if(value==""){
                this.obj.buyerName="";
                this.obj.buyerTaxNo="";
                this.obj.buyerAddressPhone="";
                this.obj.buyerBankAccount="";
            }else{
                for (let index = 0; index < this.autoData.length; index++) {
                    const element = this.autoData[index];
                    if(value==element.companyTax){
                        this.obj.buyerName=element.companyName;
                        this.obj.buyerTaxNo=element.companyTax;
                        this.obj.buyerAddressPhone=element.companyAddress;
                        this.obj.buyerBankAccount=element.companyBank;
                    }
                    
                }
            }
         },
         afterSelectName(value){
            if(value==""){
                this.obj.buyerName="";
                this.obj.buyerTaxNo="";
                this.obj.buyerAddressPhone="";
                this.obj.buyerBankAccount="";
            }else{
                for (let index = 0; index < this.autoData.length; index++) {
                    const element = this.autoData[index];
                    if(value==element.companyName){
                        this.obj.buyerName=element.companyName;
                        this.obj.buyerTaxNo=element.companyTax;
                        this.obj.buyerAddressPhone=element.companyAddress;
                        this.obj.buyerBankAccount=element.companyBank;
                    }
                    
                }
            }
            
         },
         autoSearch(param){
             clearTimeout(this.timeout);
             this.timeout = setTimeout(()=>{
                    console.log("run");
                    this.axios.post("user/company/autoComplete",param).then((res)=>{
                        this.autoData = res.data;
                    })
                }, 500);
            
         },
        add(t){
            var i=this.obj.invoiceDetailList.length-1;
            if(i<0 || this.obj.invoiceDetailList[i].goodsName.length>0){
                this.obj.invoiceDetailList.push({goodsName:'',goodsTotalPrice:null});
                this.showtitle(this.obj.invoiceDetailList[i+1],i+1)
            }else{
                 this.$Message.warning('请补齐空行数据');
            }
            

        },
        enter(index,num){
            var a=7+index*7;
            console.log(index,num,a);
            if(num<6){
                a+=num;
                console.log(a);
                $(this.$el).find('input[tabindex='+a+']').focus();
            }else if(this.obj.invoiceDetailList.length-1==index){
                console.log('add')
                this.add();
                //a=7+(index+1)*7;
                //console.log(a);
                //setTimeout(()=>{
               
                
                    
                    //$(this.$el).find('input[tabindex='+a+']').click();
                    //$(this.$el).find('input[tabindex='+a+']').click();
                //},0)
                
            }else if(this.obj.invoiceDetailList.length-1>index){
                a+=num+2;
                console.log(a);
                $(this.$el).find('input[tabindex='+a+']').focus();
            }

        },
     	showtitle(item,index,event){
            //console.log(index);
     		this.item=item;
            this.index=index;
     		this.$bus.emit('bus_libraryedit');
     	},
     	setdata(item){
     		console.log(item);
     		this.item.goodsName=item.spmc;
     		this.item.goodsTaxRate=item.zzssl.replace('%','')///100;
     		this.item.goodsCode=item.spbm;
            //this.invnum(this.item);
            if(this.item.goodsPrice && this.item.goodsTaxRate){
                this.item.goodsTotalTax=(this.item.goodsTotalPrice*(this.item.goodsTaxRate/100)).toFixed(2);
                //console.log(item.goodsTotalPrice,item.goodsTaxRate,item.goodsTotalTax)
            }
            if(typeof this.index=="number"){
                var a=7+this.index*7+1;
                $(this.$el).find('input[tabindex='+a+']').focus();
            }

            this.setcou();

     	},
        setdate(d){
            this.obj.invoiceDate=d;
        },
         showdata(params){
            this.modal=true;
            this.c={
                //orderGuid:params,
                sellerName:this.$store.getters.getUserinfo.comName,
                sellerTaxNo:this.$store.getters.getUserinfo.taxNo
            }
            //this.obj.orderGuid=params;
            this.obj.sellerName=this.$store.getters.getUserinfo.comName;
            this.obj.sellerTaxNo=this.$store.getters.getUserinfo.taxNo;
            this.obj.sellerAddressPhone=this.$store.getters.getUserinfo.addressPhone;
            this.obj.sellerBankAccount=this.$store.getters.getUserinfo.bankAccount;
            this.obj.invoiceTypeCode="1";
            this.obj.invoiceDate='';
            this.obj.invoiceTotalTax=0;
            this.obj.invoiceTotalPrice=0;
            this.obj.invoiceTotalPriceTax=0;
         },
         submit(){
                
            // this.obj={invoiceDetailList:[
            //             {goodsName:'',goodsTotalPrice:null}
            //          ]};
            // this.date='';
            // return ;
            
             
             // if(this.obj.invoiceCode==undefined || this.obj.invoiceCode==''){
             //    this.$Message.error('发票代码不能为空');
             //    this.$refs.invoiceCode.focus();
             //    return;
             // }
             if(this.obj.invoiceTypeCode==undefined || this.obj.invoiceTypeCode==''){
                this.$Message.error('请选择发票类型');
                return;
             }
             if(this.obj.buyerName==undefined || this.obj.buyerName==''){
                this.$Message.error('购买方名称不能为空');
                this.$refs.buyerName.focus();
                return;
             }
             if(this.obj.buyerTaxNo==undefined || this.obj.buyerTaxNo==''){
                this.$Message.error('购买方纳税人识别号不能为空');
                this.$refs.buyerTaxNo.focus();
                return;
             }
             if(this.obj.invoiceDate==undefined || this.obj.invoiceDate==''){
                this.$Message.error('开票日期不能为空');
                //this.$refs.invoiceDate.focus();
                return;
             }
             if(this.obj.invoiceDetailList.length>0){
                var t='';
                var u=this.obj.invoiceDetailList[0]
                //
                if(u.goodsName ==undefined || u.goodsName==''){
                    t+='服务名称,'
                    this.$refs.goodsName[0].focus()
                    
                }
                if(u.goodsQuantity ==undefined || u.goodsQuantity==''){
                    t+='数量,'
                    this.$refs.goodsQuantity[0].focus()
                    
                }
                if(u.goodsPrice ==undefined || u.goodsPrice==''){
                    t+='单价,'
                    this.$refs.goodsPrice[0].focus()
                }
                
                if(u.goodsTaxRate ==undefined || u.goodsTaxRate==''){
                    t+='税率,'
                    this.$refs.goodsTaxRate[0].focus()
                }
                if(u.goodsTotalTax ==undefined || u.goodsTotalTax==''){
                    t+='税额'
                    this.$refs.goodsTotalTax[0].focus()
                }
                //console.log(t);
                if(t!=''){
                    this.$Message.error(t+'不能为空');
                    return;
                }
             }
             if(this.obj.sellerName==undefined || this.obj.sellerName==''){
                this.$Message.error('销售方名称不能为空');
                this.$refs.sellerName.focus();
                return;
             }
             if(this.obj.sellerTaxNo==undefined || this.obj.sellerTaxNo==''){
                this.$Message.error('销售方纳税人识别号不能为空');
                this.$refs.sellerTaxNo.focus();
                return;
             }
             // if(this.obj.payee==undefined || this.obj.payee==''){
             //    this.$Message.error('收款人不能为空');
             //    this.$refs.payee.focus();
             //    return;
             // }
             if(this.obj.drawer==undefined || this.obj.drawer==''){
                this.$Message.error('开票人不能为空');
                this.$refs.drawer.focus();
                return;
             }
             
             var url='/outputinoivce/makeInvoice';
             this.setcou();
             //var c=Object.assign({},this.obj);
             var c=JSON.parse(JSON.stringify(this.obj))
             if(c.invoiceDetailList[c.invoiceDetailList.length-1].goodsName!=''){

             }else{
                c.invoiceDetailList.pop();
             }
             //c.invoiceTotalTax=0;
             //c.invoiceTotalPrice=0;
             c.invoiceDetailList.forEach((r)=>{
             	if(r.goodsTaxRate>0){
             		r.goodsTaxRate=r.goodsTaxRate/100;
             	}
             	//c.invoiceTotalTax+=Number(r.goodsTotalTax);
             	//c.invoiceTotalPrice+=Number(r.goodsTotalPrice);
             })


             console.log(c);
             this.axios.post(url,c).then((res)=>{
                 console.log(res);
                 if(res.errorCode==0){
                    //成功
                     this.modal=false;
                     this.obj={invoiceDetailList:[
                        {goodsName:'',goodsTotalPrice:null}
                     ]};
                     this.obj.invoiceTypeCode="1";
                        this.obj.invoiceDate='';
                        this.obj.invoiceTotalTax=0;
                        this.obj.invoiceTotalPrice=0;
                        this.obj.invoiceTotalPriceTax=0;
                        this.obj.sellerName=this.$store.getters.getUserinfo.comName;
                        this.obj.sellerTaxNo=this.$store.getters.getUserinfo.taxNo;
                        this.obj.sellerAddressPhone=this.$store.getters.getUserinfo.addressPhone;
                        this.obj.sellerBankAccount=this.$store.getters.getUserinfo.bankAccount;
                     this.date='';
                     //this.$Message.success('成功');
                     this.$Modal.success({
                            title: '提示',
                            content: res.data
                     });
                     
                 }else{
                    //this.$message.error(res.message);
                 }
             })   
             return ;
             
            
         },
         cancel(){
             this.modal=false;
         },settax(item,index){
             if(item.goodsTotalPrice && item.goodsTaxRate){
                var c=(item.goodsTotalPrice*(item.goodsTaxRate/100)).toFixed(2)
                console.log(c)
                item.goodsTotalTax=c;
                this.$set(this.obj.invoiceDetailList,index,item)
            }
            this.setcou();
         },inputchange(item,index){
            if(item.goodsTotalTax!="" && index==this.obj.invoiceDetailList.length-1){
                this.obj.invoiceDetailList.push({
                    goodsName:'',goodsTotalPrice:null
                })
            }
         },money(item,index){
             if(item.goodsQuantity==null || item.goodsQuantity == undefined){
                 item.goodsQuantity=0;
             }
             if(item.goodsPrice==null || item.goodsPrice == undefined){
                 item.goodsPrice=null;
             }else{
                item.goodsPrice=Number(item.goodsPrice).toFixed(2);
             }
             


            
            if(item.goodsTotalTax!=undefined && item.goodsTotalTax!=''){
                item.goodsTotalTax=Number(item.goodsTotalTax || 0).toFixed(2)
            }else{
                item.goodsTotalTax=0;
            }
            if(item.goodsTotalPrice && item.goodsTaxRate){
                var c=(item.goodsTotalPrice*(item.goodsTaxRate/100)).toFixed(2)
                console.log(c)
                item.goodsTotalTax=c;
                this.$set(this.obj.invoiceDetailList,index,item)
            }
            
            item.goodsTotalPrice=((item.goodsQuantity || 0)*(item.goodsPrice || 0)).toFixed(2);
            if(item.goodsPrice && item.goodsTaxRate){
                item.goodsTotalTax=(item.goodsTotalPrice*(item.goodsTaxRate/100)).toFixed(2);
                //console.log(item.goodsTotalPrice,item.goodsTaxRate,item.goodsTotalTax)
            }
            //this.obj.invoiceTotalPrice=0;
            this.setcou();
            if(index!=undefined){
                console.log(index);
                this.inputchange(item,index);
            }
            
         },setcou(){
             var a=0;
            this.obj.invoiceTotalTax=0;
            this.obj.invoiceTotalPrice=0;
            this.obj.invoiceDetailList.forEach((i,index)=>{
                //console.log(i.goodsTotalPrice,Number(i.goodsTotalTax))
                if(i.goodsTotalPrice>0){
                    console.log(index,i.goodsTotalPrice)
                    a+=Number(i.goodsTotalPrice) || 0;
                    this.obj.invoiceTotalPrice+=Number(i.goodsTotalPrice);
                }
                
                //console.log(a)
                
                if(i.goodsTotalTax>0){
                    console.log(index,i.goodsTotalTax)
                    a+=Number(i.goodsTotalTax) || 0;
                    this.obj.invoiceTotalTax+=Number(i.goodsTotalTax);
                }
                
                //console.log(a)
            });
            a=Number(a).toFixed(2);
            
            
            this.obj.invoiceTotalTax=this.obj.invoiceTotalTax.toFixed(2);
            this.obj.invoiceTotalPrice=this.obj.invoiceTotalPrice.toFixed(2);
            //this.obj.invoiceTotalPrice=a;
            this.$set(this.obj,'invoiceTotalPriceTax',a)

            this.obj.invoiceTotalPriceb=changeMoneyToChinese(this.obj.invoiceTotalPriceTax);
         },invnum(item){
            item.goodsQuantity=parseInt(item.goodsQuantity) || 0;
            console.log(item.goodsPrice)
            if(item.goodsPrice!=undefined){
                item.goodsPrice=Number(item.goodsPrice).toFixed(2);
            }
            //if(item.goodsPrice && item.goodsQuantity){
            item.goodsTotalPrice=((item.goodsQuantity || 0)*(item.goodsPrice || 0)).toFixed(2)
             //this.setcou();
             this.money(item);
            //}
            

         },remove(item,index){
            console.log(item,index);
            this.obj.invoiceDetailList.splice(index,1);
            this.setcou();
         }
     },created(){
         //this.$bus.on('bus_entryedit', this.showdata);
         this.showdata();
         
     },beforeDestroy(){
         //this.$bus.off('bus_entryedit',this.showdata)
     },mounted(){
        this.autoSearch({});
     }
 }
 function changeMoneyToChinese(money){  
            var cnNums = new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖"); //汉字的数字  
            var cnIntRadice = new Array("","拾","佰","仟"); //基本单位  
            var cnIntUnits = new Array("","万","亿","兆"); //对应整数部分扩展单位  
            var cnDecUnits = new Array("角","分","毫","厘"); //对应小数部分单位  
            //var cnInteger = "整"; //整数金额时后面跟的字符  
            var cnIntLast = "元"; //整型完以后的单位  
            var maxNum = 999999999999999.9999; //最大处理的数字  
              
            var IntegerNum; //金额整数部分  
            var DecimalNum; //金额小数部分  
            var ChineseStr=""; //输出的中文金额字符串  
            var parts; //分离金额后用的数组，预定义  
            if( money == "" ){  
                return "";  
            }  
            money = parseFloat(money);  
            if( money >= maxNum ){  
                $.alert('超出最大处理数字');  
                return "";  
            }  
            if( money == 0 ){  
                //ChineseStr = cnNums[0]+cnIntLast+cnInteger;  
                ChineseStr = cnNums[0]+cnIntLast  
                //document.getElementById("show").value=ChineseStr;  
                return ChineseStr;  
            }  
            money = money.toString(); //转换为字符串  
            if( money.indexOf(".") == -1 ){  
                IntegerNum = money;  
                DecimalNum = '';  
            }else{  
                parts = money.split(".");  
                IntegerNum = parts[0];  
                DecimalNum = parts[1].substr(0,4);  
            }  
            if( parseInt(IntegerNum,10) > 0 ){//获取整型部分转换  
                var zeroCount = 0;  
                var IntLen = IntegerNum.length;  
                for( var i=0;i<IntLen;i++ ){  
                    var n = IntegerNum.substr(i,1);  
                   var  p = IntLen - i - 1;  
                   var  q = p / 4;  
                   var m = p % 4;  
                    if( n == "0" ){  
                        zeroCount++;  
                    }else{  
                        if( zeroCount > 0 ){  
                            ChineseStr += cnNums[0];  
                        }  
                        zeroCount = 0; //归零  
                        ChineseStr += cnNums[parseInt(n)]+cnIntRadice[m];  
                    }  
                    if( m==0 && zeroCount<4 ){  
                        ChineseStr += cnIntUnits[q];  
                    }  
                }  
                ChineseStr += cnIntLast;  
                //整型部分处理完毕  
            }  
            if( DecimalNum!= '' ){//小数部分  
                var decLen = DecimalNum.length;  
                for(var i=0; i<decLen; i++ ){  
                    n = DecimalNum.substr(i,1);  
                    if( n != '0' ){  
                        ChineseStr += cnNums[Number(n)]+cnDecUnits[i];  
                    }  
                }  
            }  
            if( ChineseStr == '' ){  
                //ChineseStr += cnNums[0]+cnIntLast+cnInteger;  
                ChineseStr += cnNums[0]+cnIntLast;  
            }/* else if( DecimalNum == '' ){ 
                ChineseStr += cnInteger; 
                ChineseStr += cnInteger; 
            } */  
            return ChineseStr;  
  }  

</script>